home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_223 / popinfo / yesno.c < prev   
C/C++ Source or Header  |  1992-05-06  |  2KB  |  58 lines

  1. #include <intuition/intuitionbase.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <pragma/all.h>
  5. #include <proto/all.h>
  6. #include "PopInfo.i"
  7.  
  8. #define OKAY 1
  9. #define CANCEL 0
  10.  
  11. static short YesNoXYBorder[]={
  12.     0,0,101,0,101,12,0,12,0,0};
  13. static struct Border YesNoBorder={
  14.     -1,-1,1,0,JAM1,5,YesNoXYBorder,NULL};
  15. static struct IntuiText OkayText={
  16.     1,1,JAM1,5,2,NULL,"    OKAY",NULL};
  17. static struct IntuiText CancelText={
  18.     1,1,JAM1,5,2,NULL,"   CANCEL",NULL};
  19. static struct Gadget OkayGadget={
  20.     NULL,8,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  21.     (APTR)&YesNoBorder,NULL,&OkayText,NULL,NULL,OKAY,NULL};
  22. static struct Gadget CancelGadget={
  23.     &OkayGadget,120,20,100,11,GADGHCOMP,RELVERIFY,BOOLGADGET,
  24.     (APTR)&YesNoBorder,NULL,&CancelText,NULL,NULL,CANCEL,NULL};
  25.  
  26. static struct IntuiText YesNoText={
  27.     1,1,JAM1,8,7,NULL,NULL,NULL};
  28.  
  29. static struct NewWindow YesNoWindow={
  30.     50,30,230,36,0,3,GADGETUP|VANILLAKEY,ACTIVATE|RMBTRAP,&CancelGadget,
  31.     NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN};
  32.  
  33. static struct Window *QWindow;
  34. static struct IntuiMessage *MyMsg;
  35. static struct IntuitionBase *IntuitionBase;
  36.  
  37. YesNo(text)
  38. char *text;
  39. {
  40.     int Class,Code;
  41.     char key;
  42.     IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
  43.     YesNoWindow.Screen=(struct Screen *) IntuitionBase->ActiveScreen;
  44.     QWindow=(struct Window *) OpenWindow(&YesNoWindow);
  45.     YesNoText.IText=text;
  46.     PrintIText(QWindow->RPort,&YesNoText,0,0);
  47.     waitforinput:
  48.     Wait (1<<QWindow->UserPort->mp_SigBit);
  49.     MyMsg=GetMsg(QWindow->UserPort);
  50.     ReplyMsg(MyMsg);
  51.     Class=MyMsg->Class; Code=MyMsg->Code; key=toupper((char ) Code);
  52.     if (Class==VANILLAKEY && key!='Y' && key!='N') goto waitforinput;
  53.     CloseWindow(QWindow);
  54.     CloseLibrary(IntuitionBase);
  55.     if (((struct Gadget *) MyMsg->IAddress)->GadgetID==OKAY || key=='Y') return(TRUE);
  56.     return(FALSE);
  57. }
  58.